from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Firefox()
driver.maximize_window()
url = 'file:///root/NSD2408/html/registerA.html'
driver.get(url)

# 点击按钮出现弹框
sleep(2)
driver.find_element(By.CSS_SELECTOR, '#alerta').click()
sleep(3)
# 切换到弹框
alert = driver.switch_to.alert
# 获取文本内容
text = alert.text
print('弹框文本内容：', text)
# 执行点击确定/取消
# 只有一个按钮哪一个都可以
# alert.accept()  # 确定
alert.dismiss()  # 取消


sleep(3)
driver.find_element(By.CSS_SELECTOR, '#userA').send_keys('admin')
sleep(3)
driver.quit()